TKey
TValue
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.Options<TKey,TValue> Class

Glossary Item Box

Defines the options nessessary to construct a BPlusTree implementation

Object Model

BPlusTree.Options<TKey,TValue> ClassILockStrategy InterfaceILockFactory InterfaceINodeStorage Interface

Syntax

Visual Basic (Declaration) 
Public NotInheritable Class BPlusTree.Options
    (Of TKey,TValue) 
   Inherits BPlusTreeOptions(Of TKey,TValue)
C# 
public sealed class BPlusTree.Options<TKey,TValue> : BPlusTreeOptions<TKey,TValue> 

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C#Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NETCopy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>
      CSharpTest.Net.Collections.BPlusTree`2.Options<TKey,TValue>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BPlusTree.Options<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.RecoverFile(BPlusTree.Options)
IEnumerable> BPlusTree.RecoveryScan(BPlusTree.Options,FileShare)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.Options BPlusTree.Options.Clone()

Generated with Document! X 2011 by Innovasys